package keni.html.android.framework.UI;

import java.util.Map;

import com.phonegap.DroidGap;

import keni.html.android.framework.metadata.MetadataParser;
import keni.html.android.framework.metadata.PageMetadata;
import keni.html.formFlow.R;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class Html5POCActivity extends DroidGap {


	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		String errorString="";
		MetadataParser parser=new MetadataParser();
		Map<String, PageMetadata> resultMap=null;
		
		try {
			 resultMap= parser.parse(super.getBaseContext());
			
		} catch (Exception e) {
			 errorString=e.toString();
		}
		Log.e("error", errorString);
		setContentView(R.layout.main);

		WebView webView = (WebView) findViewById(R.id.webview);
		webView.addJavascriptInterface(new JsInterfaceOfMetadata(resultMap.get("page1")), "UIMetadata");

		WebSettings webSettings = webView.getSettings();
		webSettings.setJavaScriptEnabled(true);
		webSettings.setAllowFileAccess(true);
		webSettings.setBuiltInZoomControls(true);
		webView.setWebViewClient(new WebViewClient());
		webView.setWebChromeClient(new WebChromeClient());

		webView.loadUrl("file:///android_asset/UIRender/new_file2.html");
		
	
		
	}
}